<?php

namespace FoxLib\Middleware;

use Closure;
use FoxLib\Services\NonceService;
use Illuminate\Http\Request;


class NonceMiddleware
{
    const ADMIN_NONCE_KEY_PREFIX = "ADMIN_NONCE_SECRET:";

    public function handle(Request $request, Closure $next)
    {
        $userId = intval($request->header("X-Authenticated-Userid"));

        NonceService::check($userId, $request->input('nonce'));

        return $next($request);
    }
}
